//
//  EveryRestaurantViewController.m
//  南京大牌档
//
//  Created by student on 14-1-15.
//  Copyright (c) 2014年 无锡第三团队. All rights reserved.
//

#import "EveryRestaurantViewController.h"



@interface EveryRestaurantViewController ()

@end

@implementation EveryRestaurantViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.hidesBottomBarWhenPushed=YES;
        self.tabBarController.tabBar.hidden=YES;
        [self.navigationController.navigationBar setTintColor:[UIColor redColor]];
    }
    return self;
}



- (void)viewDidLoad
{
    [super viewDidLoad];
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
    {
        self.edgesForExtendedLayout = UIRectEdgeNone;
        self.extendedLayoutIncludesOpaqueBars = NO;
        self.modalPresentationCapturesStatusBarAppearance = NO;
    }
#endif
    
	self.view.backgroundColor=[UIColor whiteColor];
    [self loadCoverView];
}

-(void)sixButtonPressed:(UIButton *)button
{
    [self.view addSubview:buttonIV];
    [UIView beginAnimations:nil context:NULL];
    buttonIV.frame=button.frame;
    [UIView commitAnimations];
    everyResaurantLabel.text=_everyArray[button.tag];
    
}

-(void)signButtonPressed:(UIButton *)button
{
    if ((int)[_distance floatValue]>100) {
        UIAlertView *alertView=[[UIAlertView alloc]initWithTitle:@"提示" message:@"抱歉，你离此门店距离太远，无法签到" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alertView show];
    }
    else{
        button.userInteractionEnabled=NO;
        button.titleLabel.text=@"已经签到";
    }
}
-(void)loadCoverView
{
    

    NSMutableArray *sourceImages = [NSMutableArray arrayWithCapacity:10];
    
    [sourceImages addObject:[UIImage imageNamed:_imageArray[0]]];
    [sourceImages addObject:[UIImage imageNamed:_imageArray[1]]];
    [sourceImages addObject:[UIImage imageNamed:_imageArray[2]]];
    [sourceImages addObject:[UIImage imageNamed:_imageArray[3]]];
    [sourceImages addObject:[UIImage imageNamed:_imageArray[4]]];
    [sourceImages addObject:[UIImage imageNamed:_imageArray[5]]];
    [sourceImages addObject:[UIImage imageNamed:_imageArray[6]]];
    [sourceImages addObject:[UIImage imageNamed:_imageArray[7]]];
    [sourceImages addObject:[UIImage imageNamed:_imageArray[8]]];
    [sourceImages addObject:[UIImage imageNamed:_imageArray[9]]];

    coverFlowView = [CoverFlowView coverFlowViewWithFrame:CGRectMake(0,0, 320,144) andImages:sourceImages sideImageCount:4 sideImageScale:0.45 middleImageScale:0.8];
    
    [self.view addSubview:coverFlowView];
    
    UIButton *timeButton=[[UIButton alloc]initWithFrame:CGRectMake(20,coverFlowView.frame.origin.y+200, 30, 30)];
    timeButton.backgroundColor=[UIColor clearColor];
    [timeButton setTitle:@"☀" forState:UIControlStateNormal];
    timeButton.tag=0;
    [timeButton addTarget:self action:@selector(sixButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:timeButton];
    UILabel *timeLabel=[[UILabel alloc]initWithFrame:CGRectMake(15, coverFlowView.frame.origin.y+230, 40, 10)];
    timeLabel.backgroundColor=[UIColor clearColor];
    timeLabel.font=[UIFont systemFontOfSize:10];
    timeLabel.text=@"营业时间";
    [self.view addSubview:timeLabel];
    
    UIButton *busButton=[[UIButton alloc]initWithFrame:CGRectMake(70, coverFlowView.frame.origin.y+200, 30, 30)];
    busButton.backgroundColor=[UIColor clearColor];
    [busButton setTitle:@"🚌" forState:UIControlStateNormal];
    busButton.tag=1;
    [busButton addTarget:self action:@selector(sixButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:busButton];
    UILabel *busLabel=[[UILabel alloc]initWithFrame:CGRectMake(65, coverFlowView.frame.origin.y+230, 40, 10)];
    busLabel.backgroundColor=[UIColor clearColor];
    busLabel.font=[UIFont systemFontOfSize:10];
    busLabel.text=@"乘车导航";
    [self.view addSubview:busLabel];
    
    UIButton *happyButton=[[UIButton alloc]initWithFrame:CGRectMake(120, coverFlowView.frame.origin.y+200, 30, 30)];
    happyButton.backgroundColor=[UIColor clearColor];
    [happyButton setTitle:@"🏩" forState:UIControlStateNormal];
    happyButton.tag=2;
    [happyButton addTarget:self action:@selector(sixButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:happyButton];
    UILabel *happyLabel=[[UILabel alloc]initWithFrame:CGRectMake(115, coverFlowView.frame.origin.y+230, 40, 10)];
    happyLabel.backgroundColor=[UIColor clearColor];
    happyLabel.font=[UIFont systemFontOfSize:10];
    happyLabel.text=@"周边娱乐";
    [self.view addSubview:happyLabel];
    
    UIButton *parkButton=[[UIButton alloc]initWithFrame:CGRectMake(170, coverFlowView.frame.origin.y+200, 30, 30)];
    parkButton.backgroundColor=[UIColor clearColor];
    [parkButton setTitle:@"🚕" forState:UIControlStateNormal];
    parkButton.tag=3;
    [parkButton addTarget:self action:@selector(sixButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:parkButton];
    UILabel *parkLabel=[[UILabel alloc]initWithFrame:CGRectMake(165, coverFlowView.frame.origin.y+230, 40, 10)];
    parkLabel.backgroundColor=[UIColor clearColor];
    parkLabel.font=[UIFont systemFontOfSize:10];
    parkLabel.text=@"免费停车";
    [self.view addSubview:parkLabel];
    
    UIButton *payButton=[[UIButton alloc]initWithFrame:CGRectMake(220, coverFlowView.frame.origin.y+200, 30, 30)];
    payButton.backgroundColor=[UIColor clearColor];
    [payButton setTitle:@"💰" forState:UIControlStateNormal];
    payButton.tag=4;
    [payButton addTarget:self action:@selector(sixButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:payButton];
    UILabel *payLabel=[[UILabel alloc]initWithFrame:CGRectMake(215, coverFlowView.frame.origin.y+230, 40, 10)];
    parkLabel.backgroundColor=[UIColor clearColor];
    payLabel.font=[UIFont systemFontOfSize:10];
    payLabel.text=@"优惠信息";
    [self.view addSubview:payLabel];
    
    UIButton *sayButton=[[UIButton alloc]initWithFrame:CGRectMake(270, coverFlowView.frame.origin.y+200, 30, 30)];
    sayButton.backgroundColor=[UIColor clearColor];
    [sayButton setTitle:@"💡" forState:UIControlStateNormal];
    sayButton.tag=5;
    [sayButton addTarget:self action:@selector(sixButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:sayButton];
    UILabel *sayLabel=[[UILabel alloc]initWithFrame:CGRectMake(265, coverFlowView.frame.origin.y+230, 40, 10)];
    sayLabel.backgroundColor=[UIColor clearColor];
    sayLabel.font=[UIFont systemFontOfSize:10];
    sayLabel.text=@"消费指南";
    [self.view addSubview:sayLabel];
    
    buttonIV=[[UIImageView alloc]initWithFrame:CGRectMake(20, coverFlowView.frame.origin.y+200, 30, 30)];
    buttonIV.image=[UIImage imageNamed:@"img_kuang_selected"];
    [self.view addSubview:buttonIV];
    
    everyResaurantLabel=[[UILabel alloc]initWithFrame:CGRectMake(5, coverFlowView.frame.origin.y+240, 310, 50)];
    everyResaurantLabel.layer.cornerRadius=5;
    everyResaurantLabel.layer.borderColor = [UIColor redColor].CGColor;
    everyResaurantLabel.layer.borderWidth = 2.0;
    everyResaurantLabel.backgroundColor=[UIColor whiteColor];
    everyResaurantLabel.numberOfLines=4;
    everyResaurantLabel.font=[UIFont systemFontOfSize:10];
    everyResaurantLabel.text=@" 周一至周五:11:00-14:00 17:00-21:30\n 周六至周日:11:00-22:00\n";
    [self.view addSubview:everyResaurantLabel];
    
    
    UIButton *signButton=[[UIButton alloc]initWithFrame:CGRectMake(30, coverFlowView.frame.origin.y+340, 260, 30)];
    signButton.layer.cornerRadius=5;
    signButton.backgroundColor=[UIColor redColor];
    [signButton addTarget:self action:@selector(signButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [signButton setTitle:@"立即签到" forState:UIControlStateNormal];
    [self.view addSubview:signButton];
    UILabel *signtenLabel=[[UILabel alloc]initWithFrame:CGRectMake(30, coverFlowView.frame.origin.y+380, 260, 10)];
    signtenLabel.text=@"注:累计签到100次将获得本店优惠券";
    signtenLabel.font=[UIFont systemFontOfSize:10];
    signtenLabel.backgroundColor=[UIColor clearColor];
    [self.view addSubview:signtenLabel];

 
}

-(void)viewWillDisappear:(BOOL)animated
{
     [coverFlowView removeFromSuperview];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
